package com.cndw.kungfu.dao;

import java.util.List;
import java.util.Map;

import com.cndw.dao.jade.annotation.DAO;
import com.cndw.dao.jade.annotation.SQL;
import com.cndw.dao.jade.annotation.SQLParam;
import com.cndw.kungfu.domain.Pet;
import com.cndw.kungfu.domain.PetMode;
import com.cndw.kungfu.model.pet.domain.PetSoul;

@DAO
public interface PetDao {

	public static final String tableMode = "kfsys_pet";
	
	public static final String tablePet = "kf_player_pet";
	
	public static final String fieldsPet = "id,playerId,name,modeId,level,growth,star,spirit,perception,exp,hp,mp,maxHp,maxMp,attack,defense,hit,dodge,crit,tough,speed,skill,skillGird,hunts,score,createTime";
	
	public static final String tableSoul = "kfsys_pet_soul";
	
	public static final String fieleSoul = "id,type,name,color,level,adds,engulfExp,upgradeExp,asset,cost";

	@SQL("select id,name,icon,hp,mp,attack,defense,hit,dodge,crit,tough,speed,nextModeId from "+tableMode+" order by id asc")	
	public List<PetMode>  getPetModes();
	
	@SQL("select "+fieleSoul+" from "+tableSoul+" order by id asc ")
	public List<PetSoul> getPetSouls();

	@SQL("select max(id) from "+tablePet+" order by level asc")	
	public long getMaxPetId();

	@SQL("INSERT INTO " + tablePet + " (" + fieldsPet + ") VALUES(:p.id,:p.playerId,:p.name,:p.modeId,:p.level,:p.growth,:p.star,:p.spirit,:p.perception,:p.exp,:p.hp,:p.mp,:p.maxHp,:p.maxMp,:p.attack,:p.defense,:p.hit,:p.dodge,:p.crit,:p.tough,:p.speed,:p.skill,:p.skillGird,:p.hunts,:p.score,:p.createTime)")
	public void insert(@SQLParam("p")Pet pet);

	@SQL("UPDATE " + tablePet + " SET playerId=:p.playerId,name=:p.name,modeId=:p.modeId,level=:p.level,growth=:p.growth,star=:p.star,spirit=:p.spirit,perception=:p.perception,exp=:p.exp,hp=:p.hp,mp=:p.mp,maxHp=:p.maxHp,maxMp=:p.maxMp,attack=:p.attack,defense=:p.defense,hit=:p.hit,dodge=:p.dodge,crit=:p.crit,tough=:p.tough,speed=:p.speed,skill=:p.skill,skillGird=:p.skillGird,hunts=:p.hunts,score=:p.score,createTime=:p.createTime where id=:p.id")
	public void update(@SQLParam("p")Pet pet);

	@SQL("delete from "+tablePet+" where id=:1 ")	
	public void delete(long id);

	@SQL("select "+fieldsPet+" from "+tablePet+" where playerId=:1 order by id asc ")
	public Map<Long, Pet> getPets(long playerId);
}
